/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;

/**
 *
 * @author TT
 */
public class MyUtil {
    public static String encodeMD5(String source) {
        String result = "";
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            try {
                m.update(source.getBytes("UTF8"));
            } catch (UnsupportedEncodingException ex) {
                System.out.println(ex.getMessage());
            }
            byte s[] = m.digest();
            result = "";
            for (int i = 0; i < s.length; i++) {
                result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
            }

        } catch (NoSuchAlgorithmException ex) {
            System.out.println(ex.getMessage());
        }
        return result;
    }

    public static DecimalFormat decimalFormat = new DecimalFormat("###,###");
}
